package com.ymk.cmd;

import com.alibaba.fastjson.JSONObject;
import com.ymk.base.cmd.ACmd;
import com.ymk.base.cmd.CmdSign;
import com.ymk.base.exception.MallException;
import com.ymk.base.service.WxService;
import com.ymk.base.utlis.ParamsBuilder;
import com.ymk.bo.work.*;
import com.ymk.core.code.cmd.WorkCmdCode;
import com.ymk.core.code.resp.RespCode;
import com.ymk.core.constants.WorkConstants;
import com.ymk.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Service
public class WorkRecruitPatchCmd extends ACmd {

    @Override
    public CmdSign executeMop(HttpServletRequest request, CmdSign sign) throws Exception {
        CmdSign respSign = new CmdSign(sign);
        WorkBO reqData = super.getData(sign, WorkBO.class);
        this.setModifiedData(sign,reqData);
        this.workService.update(reqData);

        return respSign;
    }


    @Override
    public CmdSign verify(HttpServletRequest request, CmdSign sign) throws Exception {
        WorkBO reqData = super.getData(sign, WorkBO.class);
        if (Objects.isNull(reqData.getId())){
            throw new MallException("岗位id不能为空");
        }
        if (Objects.isNull(reqData.getOnRecruit())){
            throw new MallException("招聘状态不能为空");
        }

        return null;
    }

    @Override
    public String getCmdCode() {
        return WorkCmdCode.WORK_RECRUIT_PATCH;
    }
    @Override
    public boolean anon(CmdSign sign) {
        return true;
    }

    @Autowired
    private IWorkService workService;


}